package global_village.gui;

import static global_village.data.Constants.GROUP_TYPE;
import global_village.app.Utils;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.global_village.app.R;

public class Room extends Activity{

	private WebView wb;
	private String groupType;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.room);
		groupType = getIntent().getExtras().getString(GROUP_TYPE);
		initGui();
	}
	
	@SuppressLint("SetJavaScriptEnabled")
	private void initGui(){
		wb = (WebView) findViewById(R.id.room_wb);
		wb.setWebChromeClient(new WebChromeClient());
		wb.setWebViewClient(new WebViewClient());
		wb.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
		
		WebSettings ws = wb.getSettings();
		ws.setJavaScriptEnabled(true);
		
		String serverIp = Utils.getSettingsByKey("serverIp");
		
		if(groupType.equals("pub")){
			wb.loadUrl("http://" + serverIp + "/pub/pub.html");
		}else if(groupType.equals("post_office")){
			wb.loadUrl("http://" + serverIp + "/post_office/post_office.html");
		}
		
		
	}
}
